﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAO;
using Domain;

public partial class EmpVerPublicacion : System.Web.UI.Page
{
    public long? id
    {
        get
        {
            long l = 0;
            if (Request.QueryString["id"] == null ||
               !long.TryParse(Request.QueryString["id"], out l) ||
               l <= 0)
                return null;
            return l;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if(!id.HasValue)
            {
                div_content.InnerHtml = @"<ul><li class='itemerror'>Publicacion inexistente<li></ul>";
            }

            List<Publicacion> pubs = ((Empresa)Utils.operadorLogueado).Publicaciones;
            Publicacion pfinded = pubs.Find(delegate(Publicacion p)
            {
                return p.Id == id.Value;
            });
            
            div_content.InnerHtml = Server.HtmlDecode(pfinded.UltimaRevision.Datos);
        }
    }
    protected void lb_modificar_Click(object sender, EventArgs e)
    {
        Response.Redirect(Utils.SecureRedirect("~/EmpAltaPublicacion.aspx?id=" + id.Value.ToString()));
    }
}
